<template>
	<view class="container">
		<view class="m-list1">
			<view class="u-list1-itm" v-for="(item, index) in payBillList" :key="index">
				<view class="u-list1-itm-content">
					<view class="u-list1-l">
						<view class="u-list1-l-txt1 f-fw800">{{item.name}}</view>
						<view class="u-list1-l-txt2">{{item.created_at}}</view>
					</view>
					<view class="u-list1-r">
						<view class="u-list1-r-txt1 f-fw800">￥{{item.price}}</view>
						<view class="u-list1-r-txt2">待支付</view>
					</view>
				</view>
			</view>
			<view class="footer" v-show="showMore">
				暂无更多数据
			</view>
		</view>
		
	</view>
</template>

<script>
	import USER from '@/api/user/index.js'
	let app = getApp();
	
	export default {
		data() {
			return {
				payBillList: [
					{
						name: 'da',
						price: 1,
						created_at: '2020.1231231321'
					}
				],
				page: 1,
				showMore: false,
				
				user_id: '',
				face_id: ''
			}
		},
		mounted() {
			this.getBill();
		},
		methods: {
			getBill() {
				var self = this;
				self.user_id = app.globalData.intoUserId; // 用户id
				self.face_id = app.globalData.intoFaceId; // 用户id
				uni.showLoading({
					title: '获取数据中',
					mask: true
				})
				USER.billList(self.page, 10, self.user_id, self.face_id)
					.then(res => {
						uni.hideLoading();
						if (res.data.data.length == 0) {
							self.showMore = true;
						}
						self.payBillList = self.payBillList.concat(res.data.data);
					});
			},
			// 下拉刷新
			onReachBottom() {
				var self = this;
				self.page += 1;
				if (!self.showMore) {
					self.getBill();
				}
			},
		}
	}
</script>

<style scoped lang="scss">
</style>
